*******************************************************************************************************************************
*******************************************************************************************************************************
* Documentation for Reproduction of
* Rattan et al 2010 TESS Survey Experiment
* TESS Race Discrimination Meta-Analysis
* Stata version 15
* Data available here: http://www.tessexperiments.org/data/eberhardt033.html [Use the full datast]
*******************************************************************************************************************************
*******************************************************************************************************************************

* use "Rattan033FinalData", clear
set more off

*******************************************************************************************************************************
*** Racial groups
*******************************************************************************************************************************

tab PPETHM
tab PPETHM, nol

gen whiteR = PPETHM
recode whiteR (2/5=0)
tab PPETHM whiteR

gen blackR = PPETHM
recode blackR (2=1) (1=0) (3/5=0)
tab PPETHM blackR

gen hispnR = PPETHM
recode hispnR (1/3 5=0) (4=1)
tab PPETHM hispnR

*******************************************************************************************************************************
*** Treatments
*******************************************************************************************************************************

tab XTESS033 // for XTESS033, condition 1 is black joe sullivan. condition 2 is white joe sullivan.
gen treatwhite = XTESS033 - 1
tab treatwhite // for treatwhite, condition 0 is black joe sullivan. condition 1 is white joe sullivan.
gen treatblack = 0 
replace treatblack = 1 if treatwhite == 0

*******************************************************************************************************************************
*** Outcome variables
*******************************************************************************************************************************

tab Q6
tab Q6, nol
recode Q6 (-1=.)
egen opposition2life_std = std(Q6)
replace opposition2life_std = 0 - opposition2life_std

tab Q7
tab Q7, nol
recode Q7 (-1=.)
egen cruel_std = std(Q7)

tab Q8
tab Q8, nol
recode Q8 (-1=.)
tab Q8
egen capableofreform_std = std(Q8)

tab Q9
tab Q9, nol
recode Q9 (-1=.)
egen lessblame_std = std(Q9)
replace lessblame_std = 0 - lessblame_std

alpha Q6 Q7 Q8 Q9, item
gen Q6_rev = 0 - Q6
gen Q9_rev = 0 - Q9

alpha Q6_rev Q7 Q8 Q9_rev, min(2) std item gen(ALPHA)
pwcorr Q6_rev Q7 Q8 Q9_rev

sum ALPHA if whiteR==1
di r(sd)
gen ov_white_std = ALPHA/r(sd) if whiteR==1

sum ALPHA if blackR==1
di r(sd)
gen ov_black_std = ALPHA/r(sd) if blackR==1

sum ALPHA if hispnR==1
di r(sd)
gen ov_hispn_std = ALPHA/r(sd) if hispnR==1

*******************************************************************************************************************************
*** Racial manipulation check
*******************************************************************************************************************************

tab Q14 treatwhite
gen MCrace = 0
replace MCrace = 1 if (Q14==2 & treatwhite==0) | (Q14==4 & treatwhite==1)
tab MCrace
tab MCrace if white==1
tab MCrace if black==1

*******************************************************************************************************************************
*** Main regressions [Unweighted]
*******************************************************************************************************************************

reg ov_white_std treatblack if whiteR==1
reg ov_black_std treatblack if blackR==1
reg ov_hispn_std treatblack if hispnR==1
